package com.gufe.service.admin.impl.allSchool;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gufe.dto.allSchool.PageAllSchoolDTO;
import com.gufe.mapper.admin.allSchool.AllSchoolMapper;
import com.gufe.result.PageResult;
import com.gufe.service.admin.allSchool.AllSchoolService;
import com.gufe.vo.allSchool.PageAllSchoolVO;
import com.gufe.vo.allSchool.PhysicalTestVO;
import com.gufe.vo.allSchool.StudentDetailInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AllSchoolServiceImpl implements AllSchoolService {

    @Autowired
    private AllSchoolMapper allSchoolMapper;


    //分页条件查询全校人员信息
    @Override
    public PageResult getPageAllSchool(PageAllSchoolDTO pageAllSchoolDTO) {

        // 设置分页参数
        PageHelper.startPage(pageAllSchoolDTO.getPage(),pageAllSchoolDTO.getPageSize());

        //分页查询
        List<PageAllSchoolVO> pageAllSchoolVOS = allSchoolMapper.getPageAllSchool(pageAllSchoolDTO);

        // 解析查询结构并封装
        Page<PageAllSchoolVO> p = (Page<PageAllSchoolVO>) pageAllSchoolVOS;

        return new PageResult<>(p.getTotal(), p.getResult());

    }

    @Override
    public StudentDetailInfoVO getStudentDetilInfo(String studentId) {

        //获取学生基础信息
        StudentDetailInfoVO studentDetailInfoVO = allSchoolMapper.getStudentDetilInfo(studentId);

        List<PhysicalTestVO> physicalTestVOs = allSchoolMapper.getPhysicalTestVOs(studentId);

        studentDetailInfoVO.setPhysicalTestVOList(physicalTestVOs);

        return studentDetailInfoVO;
    }
}
